<template>
    <div>
        <a-modal
            :title="currentRow.type?currentRow.type:'完成抽选'"
            :visible="visible"
            :confirm-loading="confirmLoading"
            @ok="handleOk"
            @cancel="visible = false"
            :width="800"
            class='automaticAssignmentConditions-tc-modal'
            :dialogStyle="{top:'20px'}"
            
        >
            <div class="automaticAssignmentConditions-modal-box-v">
                <table border bordercolor="#d9d9d9" style="width: 100%; margin-top: 15px;">
                    <tr v-if="currentRow.type=='发送短信' && currentRow.qfType !== 'success'">
                        <td class="title-left-v">接收短信人员</td>
                        <td colspan="5">{{ currentRow.name }}</td>
                    </tr>
                    <!-- <tr>
                        <td class="title-left-v">是否发送确认短信</td>
                        <td colspan="5">
                            <compSelector
                                :key="compSelectorkey"
                                v-model="currentRow.fsmszt" 
                                :defaultValue="currentRow.fsmszt"
                                compType="Radio"
                                :options="[{
                                    label:'是',
                                    value:'是',
                                },{
                                    label:'否',
                                    value:'否',
                                }]"
                            />
                        </td>
                    </tr> -->
                    <tr v-if="currentRow.qfType !== 'success'">
                        <td class="title-left-v">短信内容</td>
                        <td colspan="5">
                            <a-textarea 
                                :key="fdqrdxnrKey"
                                :readOnly="type=='发送短信'?true:false"
                                v-model="currentRow.fdqrdxnr"
                                :autosize="{ minRows: 2, maxRows: 10000 }"
                                placeholder="请输入短信内容"
                            ></a-textarea>
                        </td>
                    </tr>
                    <tr v-if="currentRow.qfType == 'success' && rymdData">
                        <td class="title-left-v"
                         style="background-image: linear-gradient(to bottom, #e7f3ff, #fff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff);
                         background-size: 100% 35px !important;text-align:center;color:#38f;font-size:20px;" colspan="6">清空待确认抽选人员</td>
                    </tr>
                    <tr v-if="currentRow.qfType == 'success' && rymdData">
                        <td class="title-left-v">人员名单</td>
                        <td colspan="5">
                            <a-textarea 
                                readOnly
                                :key="rymdData"
                                :value="rymdData?rymdData:'无'"
                                :autosize="{ minRows: 2, maxRows: 10000 }"
                            ></a-textarea>
                        </td>
                    </tr>
                    <tr v-if="currentRow.qfType == 'success'  && rymdData">
                        <td class="title-left-v">清空原因</td>
                        <td colspan="5">
                            <a-textarea 
                                v-model="currentRow.qkyy"
                                :autosize="{ minRows: 2, maxRows: 10000 }"
                            ></a-textarea>
                        </td>
                    </tr>
                    <tr v-if="currentRow.qfType == 'success' && rymdData">
                        <td colspan="6"></td>
                    </tr>
                    <tr v-if="currentRow.qfType == 'success'">
                        <td class="title-left-v"
                         style="background-image: linear-gradient(to bottom, #e7f3ff, #fff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff);
                         background-size: 100% 35px !important;text-align:center;color:#38f;font-size:20px;" colspan="6">审评组廉政短信发送</td>
                    </tr>
                    <!-- <tr v-if="currentRow.qfType == 'success'">
                        <td class="title-left-v">人员名单</td>
                        <td colspan="5">
                            <a-textarea 
                                readOnly
                                :key="jczrymdKey"
                                :value="jczrymdData?jczrymdData:'无'"
                                :autosize="{ minRows: 2, maxRows: 10000 }"
                            ></a-textarea>
                        </td>
                    </tr> -->
                    <tr v-if="currentRow.qfType == 'success'">
                        <td class="title-left-v">短信内容</td>
                        <td colspan="5">
                            <a-textarea 
                                :key="fdqrdxnrKey"
                                v-model="currentRow.fdqrdxnr"
                                :autosize="{ minRows: 2, maxRows: 10 }"
                            ></a-textarea>
                        </td>
                    </tr>
                </table>
            </div>
        </a-modal>
    </div>
</template>
<script>
import { 
    commononeTouchHcyByAuto, 
    ybmjhybmJcyXpByAuto, 
    sqsxYwxxgetCxrySendDqrSmsNr, 
    sqsxYwxxsendQrSms, 
    sqsxYwxxgetJctzSmsContent,
    sqsxYwxxgetCxrySendDqrRyxx,
    sqsxYwxxgetJctzSmsRyxx, 
    sqsxYwxxsaveCxrySendDqrSmsNr,
    sqsxYwxxsendQrSmsSingle,
} from "./service/index";
import compSelector from '@/components/compSelector/compSelector'
export default {
    components:{
        compSelector,
    },
    props:{

    },
    data(){
        return{
            currentRow:{},
            visible:false,
            confirmLoading:false,
            compSelectorkey:null,
            fdqrdxnrKey:null,
            rymdKey:null,
            rymdData:'',
            jczrymdKey:null,
            jczrymdData:'',
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getData(row){
            this.currentRow = {
                ...row,
                fsmszt:'是',
            }
            this.compSelectorkey = Date.now()
            this.confirmLoading = false
            if(row.qfType == 'success'){
                sqsxYwxxgetCxrySendDqrRyxx({sqsxid:row.sqsxid}).then(res=>{//清空人员
                    if(res.code == 200){
                        this.rymdData = res.result
                        //console.log('获取到什么人员',res.result)
                        this.rymdKey = Date.now()
                    }else{}
                })
                sqsxYwxxgetJctzSmsRyxx({sqsxid:row.sqsxid}).then(res=>{//发短信人员
                    if(res.code == 200){
                        this.jczrymdData = res.result
                        //console.log('获取到什么人员',res.result)
                        this.jczrymdKey = Date.now()
                    }else{}
                })
                sqsxYwxxgetJctzSmsContent({sqsxid:row.sqsxid}).then(res=>{
                    if(res.code == 200){
                        this.currentRow.fdqrdxnr = res.result
                        //console.log('获取到什么短信内容',res.result)
                        this.fdqrdxnrKey = Date.now()
                    }else{}
                })
            }else{
                sqsxYwxxgetCxrySendDqrRyxx({sqsxid:row.sqsxid}).then(res=>{
                    if(res.code == 200){
                        this.rymdData = res.result
                        //console.log('获取到什么人员',res.result)
                        this.rymdKey = Date.now()
                    }else{}
                })
                sqsxYwxxgetCxrySendDqrSmsNr({sqsxid:row.sqsxid}).then(res=>{
                    if(res.code == 200){
                        this.currentRow.fdqrdxnr = res.result
                        //console.log('获取到什么短信内容',res.result)
                        this.fdqrdxnrKey = Date.now()
                    }else{}
                })
            }
            
            
        },
        handleOk(){
            if(this.currentRow.type=='发送短信' &&  !this.currentRow.fdqrdxnr){
                this.$message.warning('请输入短信内容')
                return
            }
            
            if(this.currentRow.qfType == 'success'){
                this.confirmLoading = true
                if(this.rymdData && !this.currentRow.qkyy) return this.$message.warning('请填写清空原因')
                if(!this.currentRow.fdqrdxnr) return this.$message.warning('请填写短信内容')
                this.$emit('completeTheSelectionProcessClick',this.currentRow)
            }else{
                if(this.currentRow.type=='发送短信'){
                    this.confirmLoading = true
                    sqsxYwxxsendQrSmsSingle(this.currentRow).then(res=>{
                        if(res.code == 200){
                            this.$message.success(res.message)
                            this.visible = false
                            this.$emit('refreshTableSuccess')
                        }else{
                            this.$message.warning(res.message)
                        }
                        this.confirmLoading = false
                    })
                }else{
                    this.confirmLoading = true
                    sqsxYwxxsaveCxrySendDqrSmsNr(this.currentRow).then(res=>{
                        if(res.code == 200){
                            this.$message.success(res.message)
                            this.visible = false
                            this.$emit('refreshTableSuccess')
                        }else{
                            this.$message.warning(res.message)
                        }
                        this.confirmLoading = false
                    })
                }
                
            }
            
                
        },
    }
}
</script>
<style lang="less">
.automaticAssignmentConditions-tc-modal{
    .ant-modal-body{
        padding:8px;
    }
}
.automaticAssignmentConditions-modal-box-v{
    td{
        padding: 5px;
        height: 30px;
    }
    .title-left-v{
        text-align: center;
        width: 217px;
        font-weight: 600;
        font-size: 16px;
        background-color:#e6f7ff;
        font-family: simHei;
        color: rgba(0, 0, 0, 0.85);
    }
}
</style>